#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
using i64 = long long;
bool cmp(ll a,ll b)
{
    return a > b;
}
void solve()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<int> l(n), r(n);
    for (int i = 0; i < n; ++i)
    {
        std::cin >> l[i];
    }

    for (int i = 0; i < n; ++i)
    {
        std::cin >> r[i];
    }

    std::vector<int> a;
    i64 ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (l[i] < r[i])
        {
            std::swap(l[i], r[i]);
        }

        ans += l[i];
        a.push_back(r[i]);
    }

    sort(a.begin(),a.end(), std::greater<>());
    for (int i = 0; i + 1 < k; ++i)
    {
        ans += a[i];
    }

    std::cout << ans + 1 << "\n";
}

int main()
{
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
